changing order of a double summation